package com.haixiaoke.saas.repository.dto;

import com.haixiaoke.saas.repository.pojo.MaterialGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author panda
 * @Date 2023/11/17
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Node implements Serializable {
    protected String id;
    protected String name;
    protected Integer number;
    protected List<Node> children;

    public Node(MaterialGroup group) {
        this.id = String.valueOf(group.getGroupId());
        this.name = group.getGroupName();
        this.children = group.getChildren().stream().map(Node::new).collect(Collectors.toList());
    }

}
